import 'package:equatable/equatable.dart';
import 'package:backend.purchases/domain/entities/yookassa_api/payments/yookassa_api_payment_cancellation_party.dart';

const kYookassaApiPaymentCancellationMerchantPartyValue = 'merchant';
const kYookassaApiPaymentCancellationYookassaPartyValue = 'yoo_money';
const kYookassaApiPaymentCancellationPaymentNetworkPartyValue = 'payment_network';

class YookassaApiPaymentCancellationPartyDto extends Equatable {
  const YookassaApiPaymentCancellationPartyDto._internal({
    required this.partyString,
  });

  final String partyString;

  @override
  List<Object?> get props {
    return [
      partyString,
    ];
  }

  factory YookassaApiPaymentCancellationPartyDto.fromString(String s) {
    return YookassaApiPaymentCancellationPartyDto._internal(
      partyString: s,
    );
  }

  YookassaApiPaymentCancellationParty toEntity() {
    if (partyString == kYookassaApiPaymentCancellationMerchantPartyValue) {
      return YookassaApiPaymentCancellationParty.merchant;
    }

    if (partyString == kYookassaApiPaymentCancellationYookassaPartyValue) {
      return YookassaApiPaymentCancellationParty.yookassa;
    }

    if (partyString == kYookassaApiPaymentCancellationPaymentNetworkPartyValue) {
      return YookassaApiPaymentCancellationParty.paymentNetwork;
    }

    throw UnimplementedError();
  }
}
